<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/jsp/taglib.jsp"%>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>久零体验店__收银</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="favicon.ico">
    <link href="${ctxStatic}/plugins/h+/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <%--<link href="${ctxStatic}/plugins/h+/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">--%>
    <link href="${ctxStatic}/plugins/h+/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/animate.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/style.min.css?v=4.0.0" rel="stylesheet"><base target="_blank">
    <link href="${ctxStatic}/plugins/h+/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <!--[if lt IE 8]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->
    <script>
    if(window.top !== window.self){ window.top.location = window.location;}


    </script>
    <style>
        .minimalize-styl-2a {
            padding: 4px 12px;
            margin: 5px 5px 0 20px;
            font-size: 14px;
            float: left;
        }
        .jl-logoright-name{
            margin:5px 5px 0 20px;
        }
        .logoright-name-big{
            font-size:20px;
            color:#fe6b04;
        }
        .nav-name-longwidth{
            width:300px;
        }
        .middle-checkstand{
            margin:20px auto;
            width:800px;
        }
        .checkstand_text{
            font-size:40px;
            color:#fe6b04;
        }
        .checkstand_num_input{
            height:	55px;
            text-align:right;
            font-size:30px;
        }
        .payway-yzf{
            background:url(${ctxStatic}/xmarket/img/paywaysicons.png) no-repeat;
            background-position:0 0;
            height:40px;
            display:inline-block;
            width:40px;
        }
        .payway-wx{
            background:url(${ctxStatic}/xmarket/img/paywaysicons.png) no-repeat;
            background-position:-93px 0;
            height:40px;
            display:inline-block;
            width:50px;
        }
        .payway-zfb{
            background:url(${ctxStatic}/xmarket/img/paywaysicons.png) no-repeat;
            background-position:-194px 0;
            height:40px;
            display:inline-block;
            width:40px;
        }
        .payway_icons{
            text-align:right;
        }
        .payway_icons a{
            margin:0 10px;
        }
        label.paytext{
            display:inline-block;
            font-size:20px;
        }
        .othermore{
            width:800px;
            border-top:1px solid #fafafa;
            padding-top:40px;
            margin:50px auto 20px;
            text-align:center;
        }


        .moremenus{
            margin-top: 50px;
        }
        .more-menus-a{
            background:url(${ctxStatic}/xmarket/img/more_one.png) no-repeat;
            margin: 0 auto 13px;
            display:block;
            height:40px;
        }
        .more-checkrecord{
            background-position:-4px -7px;
            width:34px;
        }
        .more-printset{
            background-position:-131px -7px;
            width:42px;
        }
        .more-cashier{
            background-position:-250px -7px;
            width:42px;
        }
        .more-printticket{
            background-position:-375px -7px;
            width:38px;
        }

        .more-menus-b{
            background:url(${ctxStatic}/xmarket/img/more_two.png) no-repeat;
            margin: 0 auto 13px;
            display:block;
            height:40px;
        }
        .more-exeset{
            background-position:-2px -7px;
            width:42px;
        }
        .more-getqrecord{
            background-position:-133px -7px;
            width:36px;
        }
        .more-changepsw{
            background-position:-255px -7px;
            width:38px;
        }
        .more-aboutjl{
            background-position:-372px -7px;
            width:42px;
        }

        /******开始:弹出*********/
        .somediv{
            text-align:center;
        }
        .autofildin{
            width: 240px !important;
            margin: 20px auto;
            border-radius: 50px !important;
            text-align:center;
        }
        .col-orange{
            color:#fe6b04;
        }
        .sometext{
            margin:10px auto;
            font-size:14px;
        }
        /******结束:弹出*********/
        .ewmImg{
            width:140px;
            height:140px;
            border:1px solid #eee;
        }
        #gift_img{
            width:140px;
            height:140px;
            border:1px solid #eee;
        }
        #gift_img canvas{
            width:140px;
            height: 140px;
            position: relative;
            left: -15px;
        }.newhomeplus{
             width:100%;
         }
        .saleTJ{
            padding:0 15px 0;
        }
        .saleTJ .saleTJlie{
            background-color:#42bef7;
            color:#fff;
            padding:16px 0;
            font-size:12px;
            border-radius:4px;
        }
        .saleTJlie div p{
            margin:0;
        }
        .saleTJlie div p.num{
            font-size:28px;
        }
        .saleTJlie div img{
            margin-top:2px;
        }
        .saleSel{
            margin:14px 0;
        }
        table.TJtable{
            width:48%;
            margin:1%;
            float:left;
            background-color:#fff;
            border:1px solid #e7e8e9;
            color:#000;
            font-size:14px;
        }
        table.TJtable tr td.bg{
            background-color:#f7f7f7;
            width:50%;
        }
        table.TJtable tr td{
            border:1px solid #e7e8e9;
            padding:8px 15px;
        }
        .padding0{
            padding:0;
        }
        .toplabel{
            padding-left:15px;
        }
        .padding07{
            padding:0 7px;
        }
        .topselect{
            width:200px;
            display:inline-block;
            margin-left:40px;
        }
    </style>
</head>

<body class="gray-bg">
<div class="row border-bottom">
    <nav class="navbar navbar-static-top" role="navigation" style="margin-bottom: 0">
        <div class="navbar-header">
            <a class="navbar-minimalize minimalize-styl-2a " href="javascript:;">
                <img src="${ctxStatic}/xmarket/img/jl_logo.png" />
            </a>
            <div class="navbar-form-custom nav-name-longwidth">
                <div class="jl-logoright-name">
                    <div class="logoright-name-big">辽宁线下体验店</div>
                    <div class="logoright-name-small">辽宁线下体验店</div>
                </div>
            </div>
        </div>
        <ul class="nav navbar-top-links navbar-right">
            <li class="hidden-xs">
                <a href="javascript:;" onclick="showGift();" class="J_menuItem" data-index="0"><i></i>发券</a>
            </li>
            <li class="hidden-xs">
                <a href="javascript:;" onclick="payGoods();" class="J_menuItem" data-index="0"><i class="fa fa-exchange"></i>商品收银</a>
            </li>
            <li class="hidden-xs">
                <a href="javascript:;" onclick="logout();" class="J_menuItem" data-index="0"><i class="fa fa-sign-out"></i> 注销</a>
            </li>
        </ul>
    </nav>
</div>
<div class="middle-checkstand row">
        <div class="col-sm-12 form-group">
            <label class="col-sm-4 checkstand_text">收银金额：</label>
            <input type="text" class="col-sm-8 checkstand_num_input" id="nummoney_input" onkeypress="somepop()"
                   onafterpaste="this.value=this.value.replace(/[^\d.]/g,'')"/>
            <%--<script type="text/javascript">
                window.onload = function()
                {
                    document.getElementById("nummoney_input").focus();
                }
            </script>--%>
        </div>
</div>
<div class="payway_icons">
    <label class="paytext">本店已开通：</label>
    <a href="javascript:;" class="payway-yzf"></a>
    <a href="javascript:;" class="payway-wx"></a>
    <a href="javascript:;" class="payway-zfb"></a>
</div>

<div class="othermore">
    <div class="row">
        <div class="col-sm-3"><a href="javascript:;" target="_self" onclick="toMoeny();" class="more-menus-a more-checkrecord"></a>收银记录</div>
        <div class="col-sm-3"><a href="javascript:;" target="_self" class="more-menus-a more-printset"></a>打印机设置</div>
        <div class="col-sm-3"><a href="javascript:;" target="_self" class="more-menus-a more-cashier" onclick="toClerk()"></a>收银员管理</div>
        <div class="col-sm-3"><a href="javascript:;" target="_self" class="more-menus-a more-printticket" onclick="toReceipt()"></a>补打小票</div>
    </div>
    <div class="row moremenus">
        <div class="col-sm-3"><a href="javascript:;" target="_self" class="more-menus-b more-exeset" onclick="toSumInfo()"></a>销售统计</div>
        <div class="col-sm-3"><a href="javascript:;" target="_self" onclick="toQuan();" class="more-menus-b more-getqrecord"></a>领券记录</div>
        <div class="col-sm-3"><a href="javascript:;" target="_self" onclick="showPWDChangePopup();" class="more-menus-b more-changepsw"></a>修改密码</div>
        <div class="col-sm-3"><a href="javascript:;" target="_self" onclick="showAbout90Popup();"  class="more-menus-b more-aboutjl"></a>关于久零</div>
    </div>
</div>

<!--弹出扫码验证 -->
<div class="modal inmodal fade" id="somethingpop" tabindex="-1" role="dialog"  aria-hidden="true">
    <div class="modal-dialog modal-md">
        <div class="modal-content">
            <div class="modal-body somediv">
                <img src="${ctxStatic}/xmarket/img/popma.png" width="120px"/>
                <div class="sometext">
                    请扫描客户手机<span class="col-orange">久零券付款码，或者手机号</span>
                </div>
                <input type="text" class="form-control autofildin" id="someinput" placeholder=""  onkeyup="phoneValidate()">
                <div class="text-right">
                    <label><input type="checkbox" class="i-checks" id="isBicheckbox" onclick="doCheckThis(this);" checked="checked">优先使用久零贝</label>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-white" onclick="ValidateUser()">确定</button>
                <button type="button" class="btn btn-white" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>


<!--弹出付款页面 -->
<div class="modal inmodal fade" id="somethingpop_payOrder" tabindex="-1" role="dialog"  aria-hidden="true">
    <div class="modal-dialog modal-md">
        <div class="modal-content">
            <div class="modal-body somediv">
                <img src="${ctxStatic}/xmarket/img/popma.png" width="120px"/>
                <div class="sometext">
                    90贝消费<span style="color:#3A5FCD">0</span>元
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    任需支付<span id="needMoney" style="color:#FF0000" >0</span>元
                </div>
                <div class="sometext">
                    请扫描客户手机支付条码
                </div>
                <div class="sometext">
                    <span class="col-orange">现金收银输入9，银联收银输入8然后确定</span>
                </div>
                <input type="text" class="form-control autofildin" id="someinputPay" placeholder=""  onkeyup="doCashPay2();">
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-white" onclick="doCashPay();">确定</button>
                <button type="button" class="btn btn-white" onclick="doCancel();"data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>

<!--手机号验证 -->
<div class="modal inmodal fade" id="popId" tabindex="-1" role="dialog"  aria-hidden="true">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <input type="hidden" id="phone_code">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title" style="font-size:16px;">请输入手机验证码</h4>
            </div>
            <div class="modal-body">
                <div class="input-group">
                    <input type="text" class="form-control" placeholder="请输入验证码" id="phone_reCode"> <span class="input-group-btn">
					<button type="button" class="btn btn-jlorange "  onclick="checkPhoneCode()">确定</button> </span>
                </div>
            </div>
        </div>
    </div>
</div>

<!--等待用户验证 -->
<div class="modal inmodal fade" id="yzUserCode" tabindex="-1" role="dialog"  aria-hidden="true">
    <div class="modal-dialog modal-sm">
        <div class="modal-content" style="margin-top:40%;">
            <div class="modal-header">
                <%--<input type="hidden" id="phone_code">--%>
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title" style="font-size:16px;">需要用户输入支付密码</h4>
            </div>
            <div class="modal-body">
                <div class="text-center">
                    <%--<input type="text" class="form-control" placeholder="请输入验证码" id="phone_reCode"> <span class="input-group-btn">--%>
                    <button type="button" class="btn btn-primary" style="text-align:center"  onclick="checkPay()">确定</button> </span>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="modal inmodal" id="myModal4" tabindex="-1" role="dialog"  aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content animated fadeIn">
            <div class="modal-header">
                <span style="font-size:18px;">发券</span>
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
            </div>
            <div class="col-sm-12 modal-body">
                <form class="form-horizontal" name="">
                    <div class="col-sm-4" >
                        <img src="" id="gift_img">
                    </div>
                    <div class="col-sm-8">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">金额</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control" id="gift_total">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">模式</label>
                            <div class="col-sm-9">
                                <select class="form-control" id="gift_type">
                                    <option value="0">默认</option>
                                    <option value="1">2%</option>
                                    <option value="2">5%</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">卡号</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control" id="gift_code">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">备注</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control" id="gift_memo">
                            </div>
                        </div>
                        <div class="form-group text-center">
                            <button class="btn btn-jlorange" type="button" onclick="proGift()">生成久零券</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="modal inmodal" id="myModal5" tabindex="-1" role="dialog"  aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content animated fadeIn" style="width:1000px;margin-left:-220px;">
            <div class="modal-header" style="padding:15px;">
                <span style="font-size:18px;">销售统计</span>
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
            </div>
            <div class="col-sm-12 modal-body padding0">
                <div class=" saleSel">
                    <div class="form-group">
                        <label class="control-label toplabel">收银员
                            <select class="form-control topselect" id="clerkList" onchange="saleSum()">
                            </select>
                        </label>
                    </div>
                </div>
                <div id="" class="">
                    <div class="container newhomeplus">
                        <div class="row">
                            <div class="col-md-3 col-xs-3 saleTJ">
                                <div class="col-sm-12 saleTJlie">
                                    <div class="col-sm-4">
                                        <img src="${pageContext.request.contextPath}/resources/plugins/h+/img/xstj-fqze.png"/>
                                    </div>
                                    <div class="col-sm-8 text-right">
                                        <p>发券总额</p>
                                        <p class="num" id="giveCoupons">0.00/p>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-3 col-xs-3 saleTJ">
                                <div class="col-sm-12 saleTJlie">
                                    <div class="col-sm-4">
                                        <img src="${pageContext.request.contextPath}/resources/plugins/h+/img/xstj-fqbs.png"/>
                                    </div>
                                    <div class="col-sm-8 text-right">
                                        <p >发券笔数</p>
                                        <p class="num" id="giveCount">0.00</p>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-3 col-xs-3 saleTJ">
                                <div class="col-sm-12 saleTJlie">
                                    <div class="col-sm-4">
                                        <img src="${pageContext.request.contextPath}/resources/plugins/h+/img/xstj-zqze.png"/>
                                    </div>
                                    <div class="col-sm-8 text-right">
                                        <p>兑券总额</p>
                                        <p class="num" id="payCoupons">0.00</p>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-3 col-xs-3 saleTJ">
                                <div class="col-sm-12 saleTJlie">
                                    <div class="col-sm-4">
                                        <img src="${pageContext.request.contextPath}/resources/plugins/h+/img/xstj-fwfje.png"/>
                                    </div>
                                    <div class="col-sm-8 text-right">
                                        <p>服务费总额</p>
                                        <p class="num" id="serviceMoney">0.00</p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-md-12 padding07">
                    <div class="" style="">
                        <table class="TJtable">
                            <tr>
                                <td class="bg">现金支付</td>
                                <td id="cashPayTotal">0.00</td>
                            </tr>
                            <tr>
                                <td class="bg">微信支付</td>
                                <td id="wxPayTotal">0.00</td>
                            </tr>
                            <tr>
                                <td class="bg">支付宝支付</td>
                                <td id="aliPayTotal">0.00</td>
                            </tr>
                            <tr>
                                <td class="bg">银行卡支付</td>
                                <td id="unionPayTotal">0.00</td>
                            </tr>
                            <table>
                                <table class="TJtable">
                                    <tr>
                                        <td class="bg">久零贝</td>
                                        <td id="coinPayTotal">0.00</td>
                                    </tr>
                                    <tr>
                                        <td class="bg">交易笔数</td>
                                        <td id="tradeCount">0</td>
                                    </tr>
                                    <tr>
                                        <td class="bg">退款笔数</td>
                                        <td id="backCount">0</td>
                                    </tr>
                                    <table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!--余额不足是否需要发券 -->
<div class="modal inmodal fade" id="modal6" tabindex="-1" role="dialog"  aria-hidden="true">
    <div class="modal-dialog modal-sm">
        <div class="modal-content" style="margin-top:40%;">
            <div class="modal-header">
                <%--<input type="hidden" id="phone_code">--%>
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title" style="font-size:16px;" id="modal6Title"></h4>
            </div>
            <div class="modal-body">
                <div class="text-center">
                    <button type="button" class="btn btn-primary" style="text-align:center"  onclick="showGift()">充值</button> </span>
                    <button type="button" class="btn btn-primary " style="text-align:center"  onclick="closeModal6()">确定</button> </span>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="${ctxStatic}/plugins/h+/js/jquery.min.js?v=2.1.4"></script>
<script src="${ctxStatic}/plugins/h+/js/bootstrap.min.js?v=3.3.5"></script>
<script src="${ctxStatic}/plugins/h+/js/content.min.js?v=1.0.0"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/iCheck/icheck.min.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/layer2.4/layer.js"></script>
<script src="${ctxStatic}/90H5/resources/assets/js/jquery.qrcode.min.js
"></script>

<script>
    var orderCode = "";//订单号
    var isCoinPay = "1";//优先使用久零贝
    var codeCount="0";//判断验证码输入次数
    var needMoney="0";

    $(function () {
        inputButtenfocus(1);
        //加载收银员
        loadClerk();
    });

    //加载收银员
    function loadClerk(){
        $.ajax( {
            url:'${pageContext.request.contextPath}/api/QTClerk/QTqueryClerk.ac',// 跳转到 action
            type:'post',
            cache:false,
            dataType:'json',
            success:function(data) {
                var list=data.return_data;
                var html='<option value="-1">全部</option>';
                for(var i=0;i<list.length;i++){
                    html+='<option value="'+list[i].user_code+'">'+list[i].personName+'</option>';
                }
                $("#clerkList").html(html);
                saleSum();
            }
        });

    }



    function toMoeny(){
        showPopup("/QTMain/toMoney.ac","收银记录");
    }

    function toQuan(){
        showPopup("/QTMain/toQuan.ac","发券记录");
    }
    function toReceipt() {
        showPopup("/QTMain/toReceipt.ac","补打小票");
    }

    function  toClerk() {
        <%--window.location.href = "${ctx}/QTClerk/QTtoClerk.ac"--%>
        var url = '${ctx}/api/QTClerk/QTtoClerk.ac';
        //自定页
        parent.layer.open({
            type: 2,
            shift:4,//动画类型
            moveType:1,
            maxmin: true,
            shadeClose: true, //开启遮罩关闭
            area: ['850px', '530px'],
            content: url,
            title : "收营员管理",
            success: function(layero, index){

            },
            cancel: function(index){
//                        $table.bootstrapTable('refresh', queryParams);
//                        return true;
            },
            close  : function(index){
//                        $table.bootstrapTable('refresh', queryParams);
            }
        });
    }
    function editPwd() {
        window.location.href = "${ctx}/QTMain/toQTEditPwd.ac"
    }

    function about90() {
        window.location.href = "${ctx}/jsp/QT/main/about90.jsp"
    }

    //老版收银
    function payGoods() {
        window.location.href = "${ctx}/qtGoods/toGoodsList.ac"
    }

    function toSumInfo() {
        $("#myModal5").modal('show');
    }
    
    //发券
    function showGift() {
        $('#gift_img').attr("src","");
        $("#gift_total").val("");
        $("#gift_type").val("0");
        $("#gift_code").val("");
        $("#gift_memo").val("");
        $("#myModal4").modal('show');
        $("#modal6").modal('hide');
    }
    function closemodal(){
        $("#myModal4").modal('hide');
    }
    function closeModal6() {
        window.location.reload();
    }
    
    //生成二维码
    function proGift() {
        var gift_total=$("#gift_total").val();
        var gift_type=$("#gift_type").val();
        var gift_card=$("#gift_code").val();
        var gift_memo=$("#gift_memo").val();
        if(isNullOrEmpty(gift_total)){
            alert("请填写金额");
        }else{
            $.ajax( {
                url:'${pageContext.request.contextPath}/qtGoods/proGift.ac',// 跳转到 action
                data:{
                    gift_total :gift_total,
                    gift_type:gift_type,
                    gift_card:gift_card,
                    gift_memo: gift_memo
                },
                type:'post',
                cache:false,
                dataType:'json',
                success:function(data) {
                    if(data.return_code=="1"){
                        $("#gift_img").attr("src",data.return_info);
                    }else{
                        alert(data.return_info);
                    }
                },
                error : function() {
                    alert("异常！");
                }
            });
        }
    }

    //跳转付款码
    function somepop(){
        var code = event.keyCode;
        var totalString= $("#nummoney_input").val();
        if(code == 13){
            //回车键
            //验证数字
            if(isNullOrEmpty(totalString)){
                $("#nummoney_input").val("");
                return ;
            }
            if(!pdNmuber(totalString)){
                $("#nummoney_input").val("");
                return ;
            }
            if(totalString<=0){
                $("#nummoney_input").val("");
                return ;
            }
            //$("#somethingpop").modal('show');
            heid_div(1);
        }else{
             //true :合法 false：不合法
            var pd=pdNmuber(totalString);
             if(pd==false){
             $("#nummoney_input").val("");
             }
        }
    }

    //验证付款码
    function phoneValidate(){
        var code = event.keyCode;
        if(code == 13){
            ValidateUser();
        }
    }


    //是否是数字或者小数，只能精确到小数点后两位
    //true :合法 false：不合法
    function pdNmuber(num){
        var pdmuber=true;
        if(!isNaN(num)){
            var dot = num.indexOf(".");
            if(dot != -1){
                var dotCnt = num.substring(dot+1,num.length);
                if(dotCnt.length > 2){
                    alert("小数位已超过2位");
                    pdmuber=false;
                }
            }
        }else{
            //alert("数字不合法");
            pdmuber=false;
        }
        return pdmuber;
    }

    //聚焦 (1:金额输入框聚焦,2:付款码扫描聚焦,3:付款界面,去掉聚焦)
    function inputButtenfocus(type){
        if(type==1){
            $("#nummoney_input").val("");
            window.setTimeout("$('#nummoney_input').focus();", 500);
        }else if(type==2){
            $("#someinput").val("");
            window.setTimeout("$('#someinput').focus();", 500);
        }else if(type==3){
            $("#someinputPay").val("");
            window.setTimeout("$('#someinputPay').focus();", 500);
        }
    }

    //QT首页 支付付款码验证(查询所需支付服务费),并且生成订单
    function ValidateUser(){
        var only_code=$("#someinput").val();
        var total=parseFloat($("#nummoney_input").val());
        var iscoin=1;//0 true 使用 勾上  ,1 false 不使用 未挂钩
        var object = new Object();
        var str = encodeURI(JSON.stringify(object));

        var msgpd="";
        var pd=true;
        if(isNullOrEmpty(only_code)){
            pd=false;
            msgpd="请填写付款码";
        }
        if(total<=0){
            pd=false;
            msgpd="金额不能小于等于0";
        }
        if(!pd){
            alert(msgpd);
            return;
        }

        if ($("#isBicheckbox").get(0).checked) {
            iscoin=0;
        }



        $.ajax( {
            url:'${pageContext.request.contextPath}/qtGoods/toValidateUser.ac',// 跳转到 action
            data:{
                only_code :only_code,
                total:total,
                iscoin:iscoin,
                json: str
            },
            type:'post',
            cache:false,
            dataType:'json',
            success:function(data) {
                if(data.error_code){
                    //接口调用成功
                    var return_code=data.return_code;
                    if(return_code=="1"){
                        //验证成功
                        if(data.return_type=="1") {
                            //如果是付款码支付
                            $("#needMoney").html(data.needMoney);
                            needMoney=data.needMoney;
                            $("#somethingpop").modal('hide');//隐藏扫码页面
                            $("#somethingpop_payOrder").modal('show');//显示付款页面
                            inputButtenfocus(3);
                        }else {
                            //手机号支付
                            $("#needMoney").html(data.needMoney);
                            needMoney=data.needMoney;
                            $("#somethingpop").modal('hide');//隐藏扫码页面
                            $("#phone_code").val(data.phone_code);//手机验证码
                            $("#phone_reCode").val("");
                            $("#popId").modal('show');//手机号验证

                        }
                    }else{
                        if(data.msg.indexOf("用户久零券余额不足")!=-1){
                            $("#modal6Title").html(data.msg);
                            $("#modal6").modal('show');
                        }else {
                            alert(data.msg);
                        }
                    }
                }else{
                    //接口调用失败
                    alert(data.msg);
                }
            },
            error : function() {
                alert("异常！");
            }
        });

    }


    //true:是空 false:不为空
    function isNullOrEmpty(strVal) {
        if (strVal == null || strVal == undefined || strVal == '' || strVal == 'undefined' || strVal == 'null' || strVal == 'NULL') {
            return true;
        } else {
            return false;
        }
    }
    function showAbout90Popup(){

        var url = '${ctx}/jsp/QT/main/about90.jsp';
        //自定页
        parent.layer.open({
            type: 2,
            shift:4,//动画类型
            moveType:1,
            maxmin: true,
            shadeClose: true, //开启遮罩关闭
            area: ['850px', '530px'],
            content: url,
            title : "修改密码",
            success: function(layero, index){

            },
            cancel: function(index){
//                        $table.bootstrapTable('refresh', queryParams);
//                        return true;
            },
            close  : function(index){
//                        $table.bootstrapTable('refresh', queryParams);
            }
        });
    }
    function showPWDChangePopup(){
        var url = '${ctx}/QTMain/toQTEditPwd.ac';
        //自定页
        parent.layer.open({
            type: 2,
            shift:4,//动画类型
            moveType:1,
            maxmin: true,
            shadeClose: true, //开启遮罩关闭
            area: ['850px', '530px'],
            content: url,
            title : "修改密码",
            success: function(layero, index){

            },
            cancel: function(index){
//                        $table.bootstrapTable('refresh', queryParams);
//                        return true;
            },
            close  : function(index){
//                        $table.bootstrapTable('refresh', queryParams);
            }
        });
    }
    function showMoneyPopup(){
        var url = '${pageContext.request.contextPath}/QTMain/toMoney.ac';
    }
    function showPopup(urlSuffix,title){
        var url = '${pageContext.request.contextPath}' + urlSuffix;
        //自定页
        parent.layer.open({
            type: 2,
            shift:4,//动画类型
            moveType:1,
            maxmin: true,
            shadeClose: true, //开启遮罩关闭
            area: ['850px', '530px'],
            content: url,
            title : title,
            success: function(layero, index){

            },
            cancel: function(index){
//                        $table.bootstrapTable('refresh', queryParams);
//                        return true;
            },
            close  : function(index){
//                        $table.bootstrapTable('refresh', queryParams);
            }
        });
    }

    function show90QuanPopup(){
        var url = '${pageContext.request.contextPath}/QTMain/toQuan.ac';
        //自定页
        parent.layer.open({
            type: 2,
            shift:4,//动画类型
            moveType:1,
            maxmin: true,
            shadeClose: true, //开启遮罩关闭
            area: ['850px', '530px'],
            content: url,
            title : "领券记录",
            success: function(layero, index){

            },
            cancel: function(index){
//                        $table.bootstrapTable('refresh', queryParams);
//                        return true;
            },
            close  : function(index){
//                        $table.bootstrapTable('refresh', queryParams);
            }
        });
    }



    //退出
    function logout(){
        swal({title: "亲 确定退出本系统吗?",
                    text: "确定后 您将到系统登录页面!",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "确定",
                    cancelButtonText:"取消",
                    closeOnConfirm: false },
                function(){
                    window.location.href="${ctx}/QTMain/toLogOut.ac";
                });
    }

    $(document).keyup(function(event){

        switch(event.keyCode) {
            case 27: layer.closeAll();;break;
        }
    });


    //付款
    function payOrderMain90(){

        var orderCode= $("#orderCode").val();
        var openid=$("#orderOpenid").val();
        var paycoin= $("#paycoin").val();
        var needMoney= $("#needMoney").val();
        var someinputPay= $("#someinputPay").val();//输入值

        var pd=true;
        if(isNullOrEmpty(someinputPay)){
            pd=false;
            msgpd="请输入参数";
        }
        if(!pd){
            alert(msgpd);
            return;
        }

        $.ajax( {
            url:'${pageContext.request.contextPath}/QTMain/toHoneWxScanQT.ac',// 跳转到 action
            data:{
                orderCode :orderCode,
                openid:openid,
                paycoin:paycoin,
                needMoney:needMoney,
                someinputPay:someinputPay
            },
            type:'post',
            cache:false,
            dataType:'json',
            success:function(data) {
                if(data.error_code){
                    //接口调用成功
                    var return_code=data.return_code;
                    var useriscoin=data.useriscoin;
                    var ewpaycoin=data.ewpaycoin;
                    if(return_code=="success"){
                        //成功
                        alert("付款--成功");
                        heid_div(3);
                    }else{
                        alert(data.msg);
                        if(ewpaycoin>0 || useriscoin>0){
                            //更新提示
                            $("#paycoin").val(useriscoin);
                            $("#needMoney").val(ewpaycoin);

                            //用于显示
                            $("#showcoin").html(useriscoin);
                            $("#showmoney").html(ewpaycoin);
                        }
                    }
                }else{
                    //接口调用失败
                    alert(data.msg);
                }
            },
            error : function() {
                alert("异常！");
            }
        });


    }

    //隐藏控件 和 初始化 (1:显示扫码，2显示付款页, 3,隐藏付款页)
    function heid_div(type){
        if(type==1){
            $("#somethingpop").modal('show');//隐藏扫码页面
            $("#somethingpop_payOrder").modal('hide');//显示付款页面
            $("#someinput").val("");//清空扫码栏
            $("#someinputPay").val("");//清空付款栏

            //用于计算
            $("#orderCode").val("");
            $("#orderOpenid").val("");
            $("#paycoin").val("");
            $("#needMoney").val("");

            //用于显示
            $("#showcoin").html("0");
            $("#showmoney").html("0");
            inputButtenfocus(2);

        }else if(type==2){
            $("#somethingpop").modal('hide');//隐藏扫码页面
            $("#somethingpop_payOrder").modal('show');//显示付款页面

            $("#someinputPay").val("");//清空付款栏
        }else if(type==3){
            $("#somethingpop").modal('hide');//隐藏扫码页面
            $("#somethingpop_payOrder").modal('hide');//显示付款页面

            $("#nummoney_input").val("");//清空付款金额栏
        }
    }
    //判断手机验证码是否正确
    function checkPhoneCode() {
        var reCode=$("#phone_reCode").val();
        var code=$("#phone_code").val();
        if(reCode==null||reCode==""){
            alert("验证码不能为空");
        }else if(reCode!=code){
            codeCount++;
            if(codeCount>=3){
                $("#popId").modal('hide');//手机号验证
                alert("错误次数过多，请重试");
            }else{
                alert("验证码不正确");
            }
        }else{
            $("#popId").modal('hide');
            $("#somethingpop_payOrder").modal('show');//显示付款页面
            inputButtenfocus(3);
            codeCount=0;
        }
    }

    //直接收银
    function doCashPay()
    {
        var object = new Object();
        var only_code=$("#someinput").val();
        var totalString= $("#nummoney_input").val();
        var params=[];
        object.only_code=only_code;
        var user_code=$("#user_code").val();
        object.user_code=user_code;
        object.is90coin=isCoinPay;
        object.total=totalString;
        object.needMoney=needMoney;
        var str = encodeURI(JSON.stringify(object));
        var userPayCode = $("#someinputPay").val();
        if(userPayCode == null || userPayCode == '')
        {
            alert("请扫支付码！");
        }else {
            if(userPayCode.substr(0, 1) == '1' || userPayCode.substr(0, 1) == '2' || userPayCode.substr(0, 1) == '9' || userPayCode.substr(0, 1) == '8'){

                $.ajax({
                    url:'${pageContext.request.contextPath}/qtGoods/toDoNewCashPay.ac',
                    type:'post',
                    data:{
                        isCoinPay : isCoinPay,
                        str : str,
                        userPayCode :userPayCode,
                        type:1,
                        onlyCode:only_code
                    },
                    cache:false,
                    dataType:'json',
                    success:function(data)
                    {
                        if(data.return_code == '1'){
                            $("#somethingpop_payOrder").modal('hide');//显示付款页面
                            alert("支付成功");
                            window.location.reload();
                        }else{
                            if(data.return_info!=null&&data.return_info.indexOf("USERPAYING-")>=0){
                                orderCode=data.orderMainId;
                                $("#phone_code").modal("hide");
                                $("#yzUserCode").modal('show');
                            }else{
                                alert(data.msg);
                            }
                        }
                    }
                });
            }else{
                alert("未知的支付方式！");
            }
        }
    }


    //切换久零贝支付选项
    function doCheckThis(obj)
    {
        if($(obj).prop("checked"))
        {
            isCoinPay = "1";
        }else{
            isCoinPay = "2";
        }
    }

    //判断用户是否付款
    function checkPay() {
        var only_code=$("#someinput").val();
        $.ajax({
            url:'${pageContext.request.contextPath}/qtGoods/checkPayAgain.ac',
            type:'post',
            data:{
                onlyCode:only_code,
                orderCode:orderCode,
                needMoney:needMoney
            },
            cache:false,
            dataType:'json',
            success:function(data)
            {
                if(data.return_code=="1"){
                    alert("付款成功！");
                    $("#yzUserCode").modal('hide');
                    window.location.reload();//刷新当前页面.
                }else{
                    alert("尚未支付成功");
                }
            }
        });
    }


    //加载销售统计
    function saleSum() {
        $("#giveCoupons").html("");
        $("#giveCount").html("");
        $("#payCoupons").html("");
        $("#serviceMoney").html("");
        $("#cashPayTotal").html("");
        $("#wxPayTotal").html("");
        $("#aliPayTotal").html("");
        $("#unionPayTotal").html("");
        $("#coinPayTotal").html("");
        $("#tradeCount").html("");
        $("#backCount").html("");
        var id=$("#clerkList").val();
        $.ajax({
            url:'${pageContext.request.contextPath}/qtGoods/saleSum.ac',
            type:'post',
            data:{
               id:id
            },
            cache:false,
            dataType:'json',
            success:function(data)
            {
                if(data.return_code=="1"){
                    $("#giveCoupons").html(data.return_data[0].giveCoupons);
                    $("#giveCount").html(data.return_data[0].giveCount);
                    $("#payCoupons").html(data.return_data[0].payCoupons);
                    $("#serviceMoney").html(data.return_data[0].serviceMoney);
                    $("#cashPayTotal").html(data.return_data[0].cashPayTotal);
                    $("#wxPayTotal").html(data.return_data[0].wxPayTotal);
                    $("#aliPayTotal").html(data.return_data[0].aliPayTotal);
                    $("#unionPayTotal").html(data.return_data[0].unionPayTotal);
                    $("#coinPayTotal").html(data.return_data[0].coinPayTotal);
                    $("#tradeCount").html(data.return_data[0].tradeCount);
                    $("#backCount").html(data.return_data[0].backCount);
                }else{
                    alert(data.return_info);
                }
            }
        });
    }
</script>
<script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>
</body>

</html>